﻿using System;
using System.Collections.Generic;
using System.Text;
using log4net.Config;
using System.IO;
using RollBackLib.src.utils;

namespace RollbackLib.src.utils
{
    public class Logger
    {
        public static void configureLogger(string[] path)
        {
            // Set up a simple configuration that logs on the console.
            BasicConfigurator.Configure();
            log4net.GlobalContext.Properties["ProcessId"] = System.Diagnostics.Process.GetCurrentProcess().Id;
            // check the log4net xml file location relative to the executable path
            string fpath = AppUtils.getFileResourcePath("log4net.xml",path);
            FileInfo log4netFileInfo = null;
            if (fpath != null)
            {
                log4netFileInfo = new FileInfo(fpath);
                log4net.Config.XmlConfigurator.Configure(log4netFileInfo);
            }
            else
            {
                //TODO:  log4net was not loadable.
            }
        }

    }
}
